<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Task extends Model
{
    protected $table = 'task';
    protected $primaryKey = 'id';

    public static function createTask($phone,$expected_time)
    {
        return self::insert([
            'phone'   => $phone,
            'expected_time'      => $expected_time,
            'created_at' => time(),
        ]);
    }

    public static function getTask($phone)
    {
        return self::where("phone",$phone)->first();
    }

    public static function updateTask($phone,$actual,$back_time,$endreason)
    {
        return self::where("phone",$phone)->update(["actual"=>$actual,"back_time"=>$back_time,'endreason'=>$endreason,'status'=>2]);
    }
}
